package stores

import (
	"jvm/nzpJvm/instructions/base"
	"jvm/nzpJvm/runtime_area"
)

// 将操作数栈中一个long存入局部变量表指定索引位置
type LSTORE struct{ base.Index8Instruction }
type LSTORE_0 struct{ base.NoOperandsInstruction }
type LSTORE_1 struct{ base.NoOperandsInstruction }
type LSTORE_2 struct{ base.NoOperandsInstruction }
type LSTORE_3 struct{ base.NoOperandsInstruction }

func (self *LSTORE) Execute(frame *runtime_area.Frame) {
	_lstore(frame, self.Index)
}
func (self *LSTORE_0) Execute(frame *runtime_area.Frame) {
	_lstore(frame, 0)
}
func (self *LSTORE_1) Execute(frame *runtime_area.Frame) {
	_lstore(frame, 1)
}
func (self *LSTORE_2) Execute(frame *runtime_area.Frame) {
	_lstore(frame, 2)
}
func (self *LSTORE_3) Execute(frame *runtime_area.Frame) {
	_lstore(frame, 3)
}
func _lstore(frame *runtime_area.Frame, index uint) {
	// 从栈帧的操作数栈中弹出一个long值，
	long := frame.OperandStack().PopLong()
	frame.LocalVars().SetLong(index,long)
}

